package com.zty.pojo;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * @author tyzhang
 * @Date: 2021/2/26 16:53
 */
@Data
@AllArgsConstructor
public class Result {

    private static final int SUCCESS_CODE = 0;
    private static final String SUCCESS_MSG = "success";

    private static final int FAIL_CODE = 1;
    private static final String FAIL_MSG = "数据异常";

    private static final int ERROR_CODE = 2;

    private int code;
    private String msg;
    private Object data;


    public static Result returnSuccess(Object data){
        return new Result(SUCCESS_CODE,SUCCESS_MSG,data);
    }

    public static Result returnFail(String msg){
        return new Result(FAIL_CODE,msg,null);
    }

    public static Result returnError(String msg){
        return new Result(ERROR_CODE,msg,null);
    }

    public static Result returnError(int code,String msg){
        return new Result(code,msg,null);
    }

}
